var express=require("express");
var router=express.Router();
var multer=require("multer");
var fs=require("fs");

var upload=multer({
  dest:"upload",
  limits:{fileSize:1024*1024*1024*15}
});

    var arr=upload.array("myfiles",5);
    var single=upload.single("myfile");

    router.get("/",function (req,res){
      res.send(req.query.name);
    });

    router.post("/up",arr,function (req,res){
       res.send(req.files);
    });

    router.get("/img/:imgName",function (req,res){
            var rs=fs.createReadStream("upload/"+req.params.imgName);
            rs.pipe(res);
    });

    module.exports=router;
